
from django.http import JsonResponse
from django.contrib.auth.mixins import LoginRequiredMixin

class LoginRequiredJSONMixin(LoginRequiredMixin):
    def dispatch(self, request, *args, **kwargs):
        if not request.user.is_authenticated:
            return JsonResponse({'code': 400, 'errmsg':'还未登录'})
        return super().dispatch(request, *args, **kwargs)

# class LoginRequiredJSONMixin(LoginRequiredMixin):
#        def handle_no_permission(self):
#             return JsonResponse({'code': 400, 'errmsg':'还未登录 '})
#
# 













